#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import rospy
from std_msgs.msg import String
from ros_mqtt.robotsys import robotsys

def heatbeat():
    pub = rospy.Publisher('MQTTHeatbeat',String,queue_size=10)
    rate = rospy.Rate(0.1)
    data = {"method": "system.handshakle","code": 1,"msg": "","battery": robotsys.battery_ratio,"liquid": robotsys.liquid_ratio}
    while not rospy.is_shutdown():
        pub.publish(str(data))
        rate.sleep()

def main():
    try:
        NODE_NAME = os.path.basename(__file__)
        rospy.init_node(NODE_NAME)
        rospy.loginfo('Start node : %s'%NODE_NAME)
        heatbeat()
    except rospy.ROSInterruptException:
        pass


if __name__ == '__main__':
    main()
